package com.xy.smartsms.iface;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.HashMap;
import java.util.Map;

/**
 * 通知栏点击事件参数序列化对象
 * @author xiaoyuan
 * */
public class IXYNotificationItem implements Parcelable {

    public Long msgId;
    public String phoneNum;
    public String smsBody;
    public HashMap<String, String> extendMap = new HashMap<>();
    public Map<String, Object> dataMap = new HashMap<>();

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static final Creator<IXYNotificationItem> CREATOR = new Creator() {

        @Override
        public IXYNotificationItem createFromParcel(Parcel source) {
            /*必须按成员变量声明的顺序读取数据，不然会出现获取数据出错*/
            IXYNotificationItem item = new IXYNotificationItem();
            item.msgId = source.readLong();
            item.phoneNum = source.readString();
            item.smsBody = source.readString();
            item.extendMap = source.readHashMap(HashMap.class.getClassLoader());
            item.dataMap = source.readHashMap(HashMap.class.getClassLoader());
            return item;
        }

        @Override
        public IXYNotificationItem[] newArray(int size) {
            return new IXYNotificationItem[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(msgId);
        dest.writeString(phoneNum);
        dest.writeString(smsBody);
        dest.writeMap(extendMap);
        dest.writeMap(dataMap);
    }

}
